package com.heima.comment.controller.v1;

import com.heima.comment.service.ArticleCommentService;
import com.heima.model.comment.dto.CommentLikeDto;
import com.heima.model.comment.dto.CommentListDto;
import com.heima.model.comment.dto.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
@Slf4j
public class ArticleCommentController {
    @Autowired
    private ArticleCommentService commentService;
    /**
     * 保存评论
     * @param dto
     * @return
     */
    @PostMapping("save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto){
        log.info("=======>{}",dto);
        return commentService.saveComment(dto);
    }

    /**
     * 文章列表查询
     * @param dto
     * @return
     */
    @PostMapping("load")
    public ResponseResult loadComment(@RequestBody CommentListDto dto){
        log.info("=======>{}",dto);
        return commentService.commentList(dto);
    }

    /**
     * 评论点赞
     * @param dto
     * @return
     */
    @PostMapping("like")
    public ResponseResult likeComment(@RequestBody CommentLikeDto dto){
        log.info("=======>{}",dto);
        return commentService.commentLike(dto);
    }
}
